import axios, {ResponseData} from 'yuxin-base/src/utils/axios'

/**
 * pms查询业务信息
 * @param
 */
export const billBizSearch = (bizType: string, like: string): Promise<ResponseData> => {
	return axios.request({
		url: `/basesearch/finance/biz_search?bizType=${bizType}&like=${like}`,
		method: 'get'
	})
}
/**
 * pms查询业务信息
 * @param bizId
 */
export const getSimpleBillByBizId = (bizId: string): Promise<ResponseData> => {
	return axios.request({
		url: `/admin/finance_bill/get_simple_bill_by_biz_id/${bizId}`,
		method: 'get'
	})
}

/**
 * pms获取账单表信息列表
 * @param data
 */
export const financeBillList = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/finance_bill/list',
		data,
		method: 'POST'
	})
}
/**
 * pms获取账单列表统计信息
 * @param data
 */
export const financeBillCountFinanceBill = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/finance_bill/count_finance_bill',
		data,
		method: 'POST'
	})
}
/**
 * pms批量处理
 * @param data
 */
export const financeBillAffirmFinanceBatch = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/finance_bill/affirm_finance_batch',
		data,
		method: 'POST'
	})
}
/**
 * pms 企业合同账单明细 批量处理
 * @param data
 */
export const affirmFinanceForDetails = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/finance/finance_bill/affirm_finance_for_details',
		data,
		method: 'POST'
	})
}

/**
 * pms批量作废
 * @param data
 */
export const financeBillAbandonFinanceBatch = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/finance_bill/abandon_finance_batch',
		data,
		method: 'POST'
	})
}
/**
 * pms批量催收
 * @param billIds 待催收账单ID集合
 */
export const urgeToPay = (billIds: string[]): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/pay_urge/urge_to_pay',
		data: {billIds},
		method: 'POST'
	})
}

/**
 * pms页面根据账单ID获取账单收支
 * @param id
 */
export const getFinanceByBillId = (id: string): Promise<ResponseData> => {
	return axios.request({
		url: `/admin/finance_bill/get_finance_by_bill_id/${id}`,
		method: 'get'
	})
}

/**
 * 添加财务收支
 * @param data
 */
export const addFinanceAndDetail = (data: object): Promise<ResponseData> => {
	return axios.request({
		data,
		url: '/admin/finance_bill/add_finance_and_detail',
		method: 'POST'
	})
}

/**
 * pms更新财务收支
 * @param data
 */
export const updateFinanceAndDetail = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/finance_bill/update_finance_and_detail',
		data,
		method: 'POST'
	})
}

/**
 * pms账单确认收付款
 * @param data
 */
export const financeBillAffirmFinance = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/finance_bill/affirm_finance',
		data,
		method: 'POST'
	})
}
/**
 * pms删除
 * @param id
 */
export const financeBillDelete = (id: string): Promise<ResponseData> => {
	return axios.request({
		url: `/admin/finance_bill/delete_finance/${id}`,
		method: 'POST'
	})
}
/**
 * 获取账单明细优惠券详情-czx
 * @param data
 */
export const getBillCouponView = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/finance/finance_bill_detail/get_bill_coupon_view',
		data,
		method: 'POST'
	})
}
/**
 * 获取派发优惠券信息列表
 * @param data
 */
export const activityDistributeList = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/activity/activity_distribute/list_by_phone',
		data,
		method: 'POST'
	})
}
/**
 * 获取最新账单明细
 * @param data
 */
export const getFinanceByBillIdView = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/finance_bill/get_finance_by_bill_id_view',
		data,
		method: 'POST'
	})
}
/**
 * 根据verifyId获取合约账单
 * @param data
 */
export const getContractByVerifyId = (verifyId: string): Promise<ResponseData> => {
	return axios.request({
		url: `/admin/finance_bill_flow/get_bill_and_verify/${verifyId}`,
		method: 'GET'
	})
}
/**
 * 账单拆分
 * @param data
 */
export const billSplit = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/finance/finance_bill/split_finance_and_detail',
		method: 'POST',
		data
	})
}

/**
 * 页面根据拆分顶级账单ID获取账单收支
 * @param data
 */
export const getFinanceByBillSplitTopId = (billId: string): Promise<ResponseData> => {
	return axios.request({
		url: `/finance/finance_bill/get_finance_by_bill_split_top_id/${billId}`,
		method: 'GET'
	})
}

/**
 * 使用优惠券后的明细信息
 * @param data
 */
export const getCouponViewAfterUserCoupon = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/finance/finance_bill_detail/get_bill_coupon_view_new',
		data,
		method: 'POST'
	})
}
